<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../js/utils.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #outer {
            width: 500px;
            height: 500px;
            background-color: aqua;
            margin: 100px auto;
            overflow: hidden;
        }

        #middle {
            width: 400px;
            height: 400px;
            background-color: bisque;
            margin: 50px auto;
            overflow: hidden;
        }

        #inner {
            width: 300px;
            height: 300px;
            background-color: blue;
            margin: 50px auto;
        }
    </style>
</head>

<body>
    <div id="outer">
        <div id="middle">
            <div id="inner">111</div>
        </div>
    </div>
    <script>
        var outer = $('outer');
        var middle = $('middle');
        var inner = $('inner');

        // dom0
        // outer.onclick = function(){
        //     console.log('outer');
        // }
        // middle.onclick = function(){
        //     console.log('middle');
        // }
        // inner.onclick = function(e){
        //     e = e || window.event;
        //     // 阻止冒泡：
        //     // 1. 标准浏览器：e.stopPropagation();
        //     // 2. IE[了解]： e.cancelBubble = true;
        //     console.log('inner');
        //     // 阻止冒泡
        //     e.stopPropagation();
        // }


        // dom2事件阻止冒泡
        outer.addEventListener('click', function(){
            console.log('outer');
        })
        middle.addEventListener('click', function(){
            console.log('middle');
        })
        inner.addEventListener('click', function(e){
            e = e || window.event;
            e.stopPropagation();
            console.log('inner');
        })
    </script>

</body>

</html>